<nav class="navbar navbar-inverse navbar-fixed-top">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <div class="navbar-brand legacy-ui">
        <% if @count -%>
        <span id="badge_count" class="badge"><%= @count %></span>
        <% end -%>
        <%= content_tag :span, l(Time.zone.today, format: current_user.prefs.title_date_format), class: 'visible-lg-inline' %>
      </div>
    </div>
    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
        <li><%= link_to t('layouts.navigation.home'), root_path, accesskey: 't', title: t('layouts.navigation.home_title') %></li>
        <li><%= link_to t('layouts.navigation.starred'), tag_path('starred'), title: t('layouts.navigation.starred_title') %></li>
        <li><%= link_to t('common.projects'), projects_path, accesskey: 'p', title: t('layouts.navigation.projects_title') %></li>
        <li><%= link_to t('layouts.navigation.tickler'), tickler_path, accesskey: 'k', title: t('layouts.navigation.tickler_title') %></li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
            <%= t('layouts.navigation.organize') %> <span class="caret"></span>
          </a>
          <ul class="dropdown-menu">
            <li><%= link_to t('common.contexts'), contexts_path, accesskey: 'c', title: t('layouts.navigation.contexts_title') %></li>
            <li><%= link_to t('common.notes'), notes_path, accesskey: 'o', title: t('layouts.navigation.notes_title') %></li>
            <li><%= link_to t('common.review'), review_path, accesskey: 'r', title: t('layouts.navigation.review_title') %></li>
            <li><%= link_to t('layouts.navigation.recurring_todos'), recurring_todos_path, title: t('layouts.navigation.recurring_todos_title') %></li>
          </ul>
        </li>
        <li class="dropdown">
          <a href="#" id="menu_view_link" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
            <%= t('layouts.navigation.view') %> <span class="caret"></span>
          </a>
          <ul class="dropdown-menu">
            <li><%= link_to t('layouts.navigation.calendar'), calendar_path, title: t('layouts.navigation.calendar_title') %></li>
            <li><%= link_to t('layouts.navigation.completed_tasks'), done_overview_path, accesskey: 'd', title: t('layouts.navigation.completed_tasks_title') %></li>
            <li><%= link_to t('layouts.navigation.feeds'), feeds_path, title: t('layouts.navigation.feeds_title') %></li>
            <li><%= link_to t('layouts.navigation.stats'), stats_path, title: t('layouts.navigation.stats_title') %></li>
            <li class="divider"></li>
            <li id="menu_view_toggle_contexts"><%= link_to(t('layouts.toggle_contexts'), "#", {:title => t('layouts.toggle_contexts_title'), :id => "toggle-contexts-nav"}) %></li>
            <li><%= link_to(t('layouts.toggle_notes'), "#", {:accesskey => "S", :title => t('layouts.toggle_notes_title'), :id => "toggle-notes-nav"}) %></li>
            <%= group_view_by_menu_entry %>
          </ul>
        </li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
            <%= t('layouts.navigation.help') %> <span class="caret"></span>
          </a>
          <ul class="dropdown-menu">
            <li><%= link_to t('layouts.navigation.help_page'), help_path %></li>
            <li><%= link_to t('layouts.navigation.integrations_'), integrations_path %></li>
            <li><%= link_to t('layouts.navigation.api_docs'), rest_api_docs_path %></li>
          </ul>
        </li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li>
          <%= render partial: "search/index" %>
        </li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
            <%= icon('fas', 'cog', class: 'hidden-xs') %>
            <%= content_tag :span, t('layouts.navigation.options'), class: 'visible-xs-inline' %>
          </a>
          <ul class="dropdown-menu">
            <li><%= link_to icon_fw('fas', 'sign-out-alt', t('common.logout')), logout_path %></li>
            <li class="divider"></li>
            <li class="dropdown-header"><%= current_user.display_name %></li>
            <li><%= link_to icon_fw('fas', 'wrench', t('layouts.navigation.preferences')), preferences_path, accesskey: 'u', title: t('layouts.navigation.preferences_title') %></li>
            <li><%= link_to icon_fw('fas', 'download', t('layouts.navigation.export')), data_path, accesskey: 'e', title: t('layouts.navigation.export_title') %></li>
            <li><%= link_to icon_fw('fas', 'upload', t('layouts.navigation.import')), import_data_path, accesskey: 'i', title: t('layouts.navigation.import_title') %></li>
            <% if current_user.is_admin? %>
            <li class="divider"></li>
            <li class="dropdown-header"><%= t('layouts.navigation.admin') %></li>
            <li><%= link_to icon_fw('fas', 'users', t('layouts.navigation.manage_users')), users_path, accesskey: 'a', title: t('layouts.navigation.manage_users_title') %></li>
            <% end %>
          </ul>
        </li>
      </ul>
    </div>
  </div>
</nav>
